package response;

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet(name = "LoginServlet", urlPatterns = "/LoginServlet")
public class LoginServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws SecurityException, IOException {
        response.setContentType("text/html;charset=utf-8");

        String username = request.getParameter("username");
        String password = request.getParameter("password");

        if ("123456".equals(username) &&"123".equals(password)) {
            response.sendRedirect("/welcome.html");
        }else {
            response.sendRedirect("/login.html");
        }
    }
    protected void doPost(HttpServletRequest request,
                          HttpServletResponse response) throws SecurityException, IOException {
        doGet(request, response);
    }
}
